package com.lza.redis;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class RedisApplication implements ApplicationContextAware {
    @Autowired
   private static ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }
    //提供在工厂中获取对象的方法 //RedisTemplate redisTemplate
    public  static  Object getBean(String beanName){
        return applicationContext.getBean(beanName);
    }
}
